use std::rc::Rc;
use std::{env, thread};
use std::iter::Map;
use std::ops::Index;
use std::sync::Arc;
use std::time;
use std::time::Duration;
use tokio::fs::File;
use tonic::transport::Server;

use legan_piping::single_file_storage::single_file_storage::SingleFileStorageSystem;
use legan_piping::message_pipe::MessagePipe;
use legan_piping::message_pipe::StoringImportance;
use crate::legan_piping::server::LeganPipingServerImpl;
use crate::legan_piping::storage::StorageSystem;
use crate::logger::logger::{FileLogger, TerminalLogger};
use crate::protocol_buffer::gen::legan_piping_server::LeganPipingServer;

/**
 * @author Dream lab software technologies muhtarjaan mahmood (مۇختەرجان مەخمۇت)
 * @email ug-project@outlook.com
 * @create date 2022-07-05 18:41:42
 * @modify date 2022-07-05 18:41:42
 * @desc [description]
*/

mod legan_piping;
mod protocol_buffer;
mod logger;
mod assets;


#[tokio::main]
async fn main() {
    println!("{}", assets::MyAppAssets::logo_text());
    let service = LeganPipingServerImpl::new(Arc::new(FileLogger::new("Server.log".to_string()).await)).await;
    let result = Server::builder()
        .add_service(LeganPipingServer::new(service))
        .serve("0.0.0.0:7999".parse().expect("Cannot parse tcp server address & port.")).await.expect("Couldn't start GRPC server.");
}
